﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using PopupControl;

namespace simpleGUI_QLQTPM
{
    public partial class ViewProviders : UserControl
    {
        private bool _isFirst = true;

        public event EventHandler ProviderChanged;

        public ViewProviders()
        {
            InitializeComponent();
            this._isFirst = true;
        }

        private void radioButton_Click(object sender, EventArgs e)
        {
            SetColors(radioButton1);
            SetColors(radioButton2);
            if (ProviderChanged != null)
            {
                if (!this._isFirst)
                {
                    ProviderChanged(this, EventArgs.Empty);
                }
                else
                {
                    this._isFirst = false;
                }
            }
        }

        private void radioButton_MouseEnter(object sender, EventArgs e)
        {
            RadioButton radio = sender as RadioButton;
            radio.ForeColor = Color.White;
            radio.BackColor = SystemColors.HotTrack;
        }

        private void radioButton_MouseLeave(object sender, EventArgs e)
        {
            SetColors(sender as RadioButton);
        }

        private static void SetColors(RadioButton radioButton)
        {
            if (radioButton.Checked)
            {
                radioButton.ForeColor = SystemColors.HighlightText;
                radioButton.BackColor = SystemColors.Highlight;
            }
            else
            {
                radioButton.ForeColor = SystemColors.WindowText;
                radioButton.BackColor = SystemColors.Window;
            }
        }

        public string ProviderName
        {
            get
            {
                if (radioButton1.Checked)
                {
                    return "Truyền thống";
                }

                return "Hiện đại";
            }
        }

        public Image ProviderImage
        {
            get
            {
                if (radioButton1.Checked)
                {
                    return radioButton1.Image;
                }
                
                return radioButton2.Image;
            }
        }
    }
}
